package cn.bincker.mybatis.encrypt.converter.impl;

import java.nio.ByteBuffer;
import java.time.LocalDate;

public class LocalDateEncryptConverter extends BaseEncryptConverter<LocalDate> {
    @Override
    public LocalDate convertNonNull(byte[] data) {
        return LocalDate.ofEpochDay(ByteBuffer.wrap(data).getLong());
    }

    @Override
    public byte[] convertNonNull(LocalDate object) {
        var result = new byte[Long.BYTES];
        ByteBuffer.wrap(result).putLong(object.toEpochDay());
        return result;
    }
}
